/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package demoserverrmiimpl;

import demoserverrmi.IServices;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import model.Map;
import controller.ControlManager;
import model.Inanimate;
import view.MainWindow;
/**
 *
 * @author alulab11
 */
public class ServicesImpl extends UnicastRemoteObject  implements IServices {
static ControlManager m = new ControlManager();
    public ServicesImpl() throws RemoteException{        
    }
    
    @Override
    public String greetings(String name) throws RemoteException {
        System.out.println("El valor enviado es " + name);        
        return "Hola " + name +", como esta la familia?";
    }
    @Override
    public Map MapaRemoto() throws RemoteException {
        m.loadMap("DB.xml");
        Map map = m.getMap();
        if(map==null) System.out.println("Mapa nulo"); 
        return m.getMap();
    }
        @Override
    public Map MapaRemotoActualizado() throws RemoteException {
        Map map = m.getMap();
        if(map==null) System.out.println("Mapa nulo"); 
        return m.getMap();
    }
    
   @Override
    public void EnivarMapaActualizado(Map mapaNuevo) throws RemoteException {
        m.setMap(mapaNuevo);
        if(m.getMap()==null) System.out.println("Mapa nulo"); 
        m.save("DB.xml");
    }  
}